<?php
require_once("alipay_config.php");

$parameter = array(
"service" => "trade_create_by_buyer", //交易类型，必填实物交易＝trade_create_by_buyer（需要填写物流） 虚拟物品交易＝create_digital_goods_trade_p 捐赠＝create_donate_trade_p
"partner" =>$partner,                                               //合作商户号
"return_url" =>$return_url,  //同步返回
"notify_url" =>$notify_url,  //异步返回
"_input_charset" => $_input_charset,                                //字符集，默认为GBK
"subject" => $array['order']['p_name'],                           //商品名称，必填
"body" => $array['order']['p_name'],                              //商品描述，必填
"out_trade_no" => $array['order']['sp_code'],          //商品外部交易号，必填,每次测试都须修改
"price" => $array['order']['unit_price'],                                 //商品单价，必填
"discount"=>"",                                    //折扣        
"payment_type"=>"1",                               // 商品支付类型 1 ＝商品购买 2＝服务购买 3＝网络拍卖 4＝捐赠 5＝邮费补偿 6＝奖金
"quantity" => $array['order']['buy_num'],                                 //商品数量，必填
"show_url" => $array['url'],            		//商品相关网站
"logistics_type"=>$array['order']['tf_type'],                  //物流类型：VIRTUAL＝虚拟物品 POST＝平邮 EMS＝EMS EXPRESS＝其他快递公司
"logistics_fee"=>$array['order']['tf_fee'],                          //物流费用
"logistics_payment"=>$array['transfee'],                //物流支付类型: SELLER_PAY=卖家支付 BUYER_PAY=买家支付 BUYER_PAY_AFTER_RECEIVE=货到付款
"seller_email" => $seller_email,                //卖家邮箱，必填
);


//根据交易流水号产生链接
if($array['order']['alipay_id'] != ''){
	$link = "https://www.alipay.com/trade/query_trade_detail.htm?trade_no=".$array['order']['alipay_id']."&dt_from=";
}else{
	require_once("alipay_service.php");
	$alipay = new alipay_service($parameter,$security_code,$sign_type);
	$link=$alipay->create_url();
}
header("location: $link");exit;
?>

